package com.ace.lab.users.service;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletableFutureServer {

    private CompletableFutureService1 service1 = new CompletableFutureService1();
    private CompletableFutureService2 service2 = new CompletableFutureService2();

    public CompletableFuture<Double> power(String input) throws ExecutionException, InterruptedException {
        return CompletableFuture.supplyAsync(() -> service1.parse(input))
                .thenApplyAsync(x -> service2.power(x));
    }
}
